#include "StdAfx.h"
#include ".\guildmember.h"
#include <Struct.h>

__IMPL_GUILDPOOL(GuildMember)
GuildMember::GuildMember(void)
{
}

GuildMember::~GuildMember(void)
{
}

VOID GuildMember::InitializeMember()
{
	m_state			= eGUILD_MEMBER_STATE_READY;
	m_CharGuid		= 0;
	m_tszCharName[MAX_CHARNAME_LENGTH]='\0';
	m_Position		= eGUILD_TEMPORARYSOLDIER;
	m_bLogIn		= FALSE;
}

VOID GuildMember::ReleaseMember()
{

}

VOID GuildMember::LogIn( CHARGUID guid )
{
	SetCharGuid( guid );
	SetLogIn( TRUE );
	SetMemberState( eGUILD_MEMBER_STATE_READY );

}
VOID GuildMember::Join( CHARGUID guid, const TCHAR * tszCharName, BYTE byClass, LEVELTYPE CharLV )
{
	SetCharGuid( guid );
	SetCharName( tszCharName );
	SetPosition( eGUILD_TEMPORARYSOLDIER );
	SetCharClass( byClass );
	SetCharLV( CharLV );
	SetLogIn( TRUE );
}
VOID GuildMember::OnSelect( BASE_GUILD_MEMBER_INFO & IN rInfo )
{
	Serialize( rInfo, SERIALIZE_STORE );

	SetMemberState( eGUILD_MEMBER_STATE_START );
}

VOID GuildMember::Serialize( BASE_GUILD_MEMBER_INFO & INOUT rInfo, eSERIALIZE se )
{
	if( se == SERIALIZE_LOAD )
	{
		rInfo.m_CharGuid = GetCharGuid();
		memcpy( rInfo.m_tszCharName, GetCharName(), MAX_CHARNAME_LENGTH*sizeof(TCHAR) );
		rInfo.m_byPosition = GetPosition();
		rInfo.m_byClass = GetCharClass();
		rInfo.m_LV = GetCharLV();
	}
	else
	{
		SetCharGuid( rInfo.m_CharGuid );
		SetCharName( rInfo.m_tszCharName );
		SetPosition( (eGUILD_MEMBER)rInfo.m_byPosition );
		SetCharClass( rInfo.m_byClass );
		SetCharLV( rInfo.m_LV );
	}
}

VOID GuildMember::Serialize( GUILD_MEMBER_INFO & INOUT rInfo, eSERIALIZE se )
{
	if( se == SERIALIZE_LOAD )
	{
		rInfo.m_CharGuid = GetCharGuid();
		memcpy( rInfo.m_tszCharName, GetCharName(), MAX_CHARNAME_LENGTH*sizeof(TCHAR) );
		rInfo.m_byPosition = GetPosition();
		rInfo.m_byClass = GetCharClass();
		rInfo.m_LV = GetCharLV();
		rInfo.m_byIsLogin = GetLogIn();
	}
	else
	{
		SetCharGuid( rInfo.m_CharGuid );
		SetCharName( rInfo.m_tszCharName );
		SetPosition( (eGUILD_MEMBER)rInfo.m_byPosition );
		SetCharClass( rInfo.m_byClass );
		SetCharLV( rInfo.m_LV );
		SetLogIn( rInfo.m_byIsLogin );
	}
}

